let set = (key,value) => {
    if(key && value){
      try{
        let json = JSON.stringify(value)
        localStorage.setItem(key,json)
      }catch(e){
        console.error(e);
      }
    }else{
      console.error('key 和 value必须传递')
    }
}

let get = (key) => {
    let res = localStorage.getItem(key);
    try{
      let result = JSON.parse(res)
      return result
    }catch(e){
      console.log(e);
      return res
    }
  }

let rm = key => {
  localStorage.removeItem(key)
}

export default {
    set,
    get,
    rm
  }